package ema.tpjee.banking.controler;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ema.tpjee.utils.ServletUtils;

/**
 * Servlet implementation class for Servlet: BankControler
 * les dao sont dï¿½tenus par les servlets, ils sont partagï¿½s pas toutes les sessions, ils sont stateless
 * 
 * 
 */
public class BankControler extends javax.servlet.http.HttpServlet implements
		javax.servlet.Servlet {
	static final long serialVersionUID = 1L;

	


	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
			
		ServletUtils.debugRequestParameters(this.getClass(), request);
		ServletUtils.debugSessionAttributes(this.getClass(), request);

		String page_ = request.getParameter("page");
		String cmd = request.getParameter("cmd");
		
		String  formbeanclassname = request.getParameter("formbeanclass");

		System.out.println("cmd = " + cmd);


		String fw = null;

		if ("clients".equals(cmd))
			fw = "/customer.do"; 
			else if (page_ != null && !"null".equals(page_))
			fw = "/pages/" + page_ + ".jsp";
		else
			fw = "/pages/bank.jsp";


		System.out.println("forwarding to: " + fw);
		getServletContext().getRequestDispatcher(fw).forward(request, response);
	}

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
	 *      HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}


}